//
//  LandlordHomeHeaderView.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/2.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "LandlordHomeHeaderView.h"

@implementation LandlordHomeHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initControl];
    }
    return self;
}

- (void)initControl{
    
    self.backgroundColor = [UIColor whiteColor];
    
    UIImageView *imgView = [[UIImageView alloc]init];
    [imgView sd_setImageWithURL:[NSURL URLWithString:@"https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3468277972,3030817971&fm=27&gp=0.jpg"] placeholderImage:nil];
    [self addSubview:imgView];
    [imgView makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.bottom.equalTo(@-70);
    }];
    
    UIImageView *headImgView = [[UIImageView alloc]init];
    [headImgView setRoundImageWithURL:@"https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=4036889747,3526425271&fm=27&gp=0.jpg" placeholderImage:nil];
    [self addSubview:headImgView];
    [headImgView makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@80);
        make.centerX.equalTo(imgView.centerX);
        make.centerY.equalTo(imgView.centerY);
    }];
    
    UIView *darkView = [[UIView alloc]init];
    darkView.backgroundColor = RGBACOLOR(0, 0, 0, 0.3);
    [self addSubview:darkView];
    [darkView makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.bottom.equalTo(imgView.bottom);
    }];
    
    UILabel *nameLabel = [[UILabel alloc]init];
    nameLabel.font = [UIFont boldSystemFontOfSize:18];
    nameLabel.textColor = [UIColor whiteColor];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.text = @"丽江花园别墅";
    [self addSubview:nameLabel];
    [nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.right.equalTo(@-10);
        make.height.equalTo(@30);
        make.top.equalTo(headImgView.bottom).offset(10);
    }];
    
    
    for (int i=0; i<2; i++) {
        UILabel *topLabel = [[UILabel alloc]init];
        topLabel.font = [UIFont systemFontOfSize:15];
        topLabel.textColor = kSecTitleColor;
        topLabel.textAlignment = NSTextAlignmentCenter;
        topLabel.text = i==0?@"平均回复时间":@"回复率";
        [self addSubview:topLabel];
        [topLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(i==0?0:self.frame.size.width/2));
            make.width.equalTo(@(self.frame.size.width/2));
            make.height.equalTo(@20);
            make.top.equalTo(imgView.bottom).offset(10);
        }];
        
        UILabel *messLabel = [[UILabel alloc]init];
        messLabel.font = [UIFont systemFontOfSize:15];
        messLabel.textColor = kTitleColor;
        messLabel.textAlignment = NSTextAlignmentCenter;
        messLabel.text = i==0?@"1分钟":@"100%";
        [self addSubview:messLabel];
        [messLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(topLabel.left);
            make.right.equalTo(topLabel.right);
            make.height.equalTo(@20);
            make.top.equalTo(topLabel.bottom).offset(5);
        }];
        
    }
    
    UIView *lineView = [[UIView alloc]init];
    lineView.backgroundColor = kLineColor;
    [self addSubview:lineView];
    [lineView makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@0.5);
        make.centerX.equalTo(self.centerX);
        make.top.equalTo(imgView.bottom).offset(5);
        make.bottom.equalTo(self.bottom).offset(-5);
    }];
    
    UIView *btView = [[UIView alloc]init];
    btView.backgroundColor = kPageBackgroundColor;
    [self addSubview:btView];
    [btView makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(@0);
        make.height.equalTo(@10);
    }];
    
}
@end
